<?php
class HomeController 
	extends MyApplicationController
{
	private $o_subNavi;
	private $arr_appConf;
	
	public function start()
	{
		/*
		$errCount = 0;
		
		
		
		//persist command to persist in db
		try {
			$newUser = new User();
			$newUser->setUserName('ayo5');
			$newUser->setUserPass('ayo5');
			Doctrine::get()->em->persist($newUser);
		} catch (Exception $e) {
			$errCount++;
		}
		if($errCount == 0)
		{
			//commit command
			//Doctrine::get()->em->flush();
		}
		*/
		$this->subApplicationOne();
		
		/*
		parent::start();
		//get the application configuration array from the applications that were configured
		$this->registry->template->s_subAppDisplay = 'main';
		$this->arr_appConf = fw_util_getAppConfArr();
		$this->renderView();
		*/
	}
	
	private function renderView()
	{
		$this->showNavi();
		$this->registry->template->s_subNavi = $this->showSubNavi();
		$this->registry->template->show('Skeleton.php');
	}
	
	private function showSubNavi()
	{
		$arr_options = array(
			'pretty_urls'=> false,
			'is_sub_navi'=> true,
			'parent_app_alias'=> $this->arr_appConf['controller_class_alias']
		);
		$arr_subApps = $this->arr_appConf['sub_applications'];

		$this->o_subNavi = new ClaycodeNaviMenu($arr_subApps, $arr_options);
		$subNaviHtml = $this->o_subNavi->getNaviHtml();
		return $subNaviHtml;
	}
	
	public function subApplicationOne()
	{
		parent::start();
		$this->arr_appConf = fw_util_getAppConfArr();
		$this->registry->template->s_mainAppDisplay = 'subApplicationOne';
		$this->renderView();
	}
	
	public function subApplicationTwo()
	{
		parent::start();
		$this->arr_appConf = fw_util_getAppConfArr();
		$this->registry->template->s_mainAppDisplay = 'subApplicationTwo';
		$this->renderView();
	}
}
